//package com.hd.sup.core.listener;
//
//import com.hd.sup.config.mqtt.consumer.GpsConsumer;
//import com.hd.common.constant.BizConstant;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.lang3.StringUtils;
//import org.eclipse.paho.client.mqttv3.MqttClient;
//import org.eclipse.paho.client.mqttv3.MqttException;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.context.event.ContextRefreshedEvent;
//import org.springframework.stereotype.Component;
//
//import javax.annotation.Resource;
//import java.util.Arrays;
//
///**
// * @author chentl
// * @version V1.0
// * @Project 交通运输第三方监测平台
// * @Title ApplicationListener.java
// * @Description 启动监听器s
// * @Package com.hd.sup.core.listener
// * @date 2020/12/24 10:28 上午
// * @Copyright: 深圳市宏电技术股份有限公司 All rights reserved.
// */
//@Slf4j
//@Component
//public class ApplicationListener implements org.springframework.context.ApplicationListener<ContextRefreshedEvent> {
//
//
//    @Value("${mqtt.consumer.defaultTopic}")
//    private String defaultTopic;
//    @Value("${mqtt.consumer.qos}")
//    private Integer qos;
//
//    @Resource
//    private MqttClient mqttClient;
//
//    @Resource
//    private GpsConsumer gpsConsumer;
//
//    @Override
//    public void onApplicationEvent(ContextRefreshedEvent event) {
//        String[] topics = StringUtils.split(defaultTopic, BizConstant.Common.SEPARATOR.key());
//
//        if (topics.length == 0) {
//            log.info("[mqtt] mqtt客户端启动失败，topic为空");
//            return;
//        }
//
//        Arrays.stream(topics).forEach(topic -> {
//            try {
//                mqttClient.subscribe(topic, qos, gpsConsumer);
//            } catch (MqttException e) {
//                log.error("[mqtt] mqtt客户端订阅失败");
//            }
//        });
//
//        log.info("[mqtt] mqtt客户端启动成功!");
//
//    }
//
//}
